package com.mingqijia.gassafety.db.mapper;

import com.mingqijia.gassafety.db.entity.WorkOrderHistory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mingqijia.gassafety.db.entity.vo.DeviceOrderCustTypeVO;
import com.mingqijia.gassafety.db.entity.vo.WorkOrderAndSmartKitVO;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Param;

/**
 * <p>
 * 工单记录表 Mapper 接口
 * </p>
 *
 * @author guoliang.lao
 * @since 2022-09-15
 */
@Repository
@Mapper
public interface WorkOrderHistoryMapper extends BaseMapper<WorkOrderHistory> {

    WorkOrderHistory selectPkidByImei(@Param("imei") String imei,@Param("spId") String spId
            ,@Param("orderType") Integer orderType,@Param("orderChannel") Integer orderChannel);

    List<WorkOrderHistory> queryPkidByImeis(@Param("imeiList") List<String> imeiList,@Param("spId") String spId
            ,@Param("orderType") Integer orderType,@Param("orderChannel") Integer orderChannel);

    int selectCountByImei(@Param("imei") String imei,@Param("spId") String spId);

    int queryCountByImei(@Param("imeiList") List<String> imeiList,@Param("spId") String spId);


    /**
     * 根据工单号查询工单和smartKit数据
     * @param recordIds
     */
    List<WorkOrderAndSmartKitVO> selectWorkOrderAndSmartKitByRecordId(@Param("recordIds") List<String> recordIds);

    List<WorkOrderHistory> selectBySubsCode(@Param("subsCode") String subsCode, @Param("spId")String spId);

    WorkOrderHistory selectByOrderNo(@Param("orderNo") String orderNo);

    List<DeviceOrderCustTypeVO> selectDeviceLastUseCustType(@Param("spId")String spId, @Param("deviceIds") List<String> deviceIds);

    /**
     * 获取客户最新的发起工单类型信息
     * @param spId
     * @param consumerId
     * @return
     */
    DeviceOrderCustTypeVO selectLastUseCustTypeByConsumerId(@Param("spId")String spId,
                                                          @Param("consumerId") Integer consumerId);

    /**
     * 获取客户的最新的发起工单类型【批量】
     * @param spId
     * @param consumerIds
     * @return
     */
    List<DeviceOrderCustTypeVO> selectLastUseCustTypeByConsumerIds(@Param("spId")String spId,
                                                                   @Param("consumerIds") List<Integer> consumerIds);

}
